package com.bb.flow.api.entries;


import com.bb.flow.api.type.ExecuteState;
import com.bb.flow.config.enumtype.NodeType;

/**
 * @author bigbeard  on 2017/7/7.
 * 节点执行结果 监听返回对象
 */
public class NotifyNodeExecuteInfo extends NodeNotifyInfo {
    /**
     * 上下文
     */
    private final Object flowContext;

    /**
     * 节点执行状态
     */
    private final ExecuteState state;

    /**
     * 发生时间
     */
    private final long timeStamp;
    /**
     * 父流程信息
     */
    private final NotifyParentFlowInfo parentFlowInfo;

    /**
     * @param flowTemplateName 流程模版名称
     * @param nodeKey          节点名称
     * @param state            状态
     * @param flowContext      上下文
     * @param nodeType         节点类型
     * @param flowInstanceName 流程实例名称
     * @param parentFlowInfo   父流程信息
     */
    public NotifyNodeExecuteInfo(
            String flowTemplateName, String nodeKey
            , ExecuteState state
            , Object flowContext, NodeType nodeType
            , String flowInstanceName, NotifyParentFlowInfo parentFlowInfo) {
        this.setFlowTemplateName(flowTemplateName);
        this.setNodeKey(nodeKey);
        this.state = state;
        this.flowContext = flowContext;
        this.setNodeType(nodeType.toString());
        this.setFlowInstanceName(flowInstanceName);
        this.parentFlowInfo = parentFlowInfo;
        this.timeStamp = System.currentTimeMillis();
    }

    /**
     * 父流程信息
     *
     * @return 当前对象, 父流程信息
     */
    public NotifyParentFlowInfo getParentFlowInfo() {
        return parentFlowInfo;
    }

    /**
     * 获取流程上下文信息
     *
     * @return 流程上下文
     */
    public Object getFlowContext() {
        return flowContext;
    }

    /**
     * 获取状态
     *
     * @return 状态
     */
    public ExecuteState getState() {
        return state;
    }

    /**
     * 获取时间戳
     *
     * @return 时间戳
     */
    public long getTimeStamp() {
        return timeStamp;
    }
}
